Imports System.Data.SqlClient
Imports System.Data
Imports CAPA_Entidad
Imports CAPA_Utilitarios
Public Class DocumentoClienteDetallePickeadorDatos

    'Se crea una instancia unica para las conexiones
    Dim conex As Conexion = Conexion.getInstance()

    Function obtenerDADCodigoXART(ByVal codPedido As String, ByVal codArticulo As String) As Integer
        Dim numero As Integer = 0
        Dim con As SqlConnection = conex.obtenerConexion()

        Try
            con.Open()

            Dim query As String = "SELECT DAD_Codigo " & _
                                  "FROM Documento_Almacen_Detalle " & _
                                  "WHERE ART_Codigo = '" & codArticulo & "' " & _
                                  "AND DAD_Activo = '1' AND " & _
                                  "TDOC_Codigo = 'PK' " & _
                                  "AND DCA_Codigo = '" & codPedido & "'"

            Dim adapter As SqlDataAdapter = New SqlDataAdapter(query, con)
            Dim ds As New DataSet
            adapter.Fill(ds)

            numero = CInt(ds.Tables(0).Rows(0)("DAD_Codigo").ToString.Trim)
        Catch ex As Exception
            numero = -1
        Finally
            con.Close()
        End Try

        Return numero
    End Function

End Class
